<template>
  <div class="box">
    <van-swipe :autoplay="3000">
      <van-swipe-item v-for="(image, index) in list" :key="index">
        <img class="lbo" :src="image.img_url" />
      </van-swipe-item>
    </van-swipe>
    <ul>
      <li
        v-for="item in arr"
        :key="item.id"
        @click="
          $router.push({
            path: '/xiang',
            query: {
              id: item.id,
            },
          })
        "
      >
        <img :src="item.cover_url" alt="" />
        <span>{{ item.title }}</span>
        <span>￥{{ item.price }}</span>
        <span>已售{{ item.stock }}</span>
      </li>
    </ul>
  </div>
</template>

<script>
export default {
  data() {
    return {
      list: [],
      arr: [],
      current: 1,
    };
  },
  mounted() {
    this.$axios.get("/api/index", this.current).then((res) => {
      console.log(res);
      this.list = res.data.slides;
      this.arr = res.data.goods.data;
    });
  },
};
</script>

<style>
.box {
  width: 100%;
  height: 100%;
}
.van-swipe {
  width: 100%;
}
ul {
  display: flex;
  width: 100%;
  flex-wrap: wrap;
}
li {
  display: flex;
  width: 50%;
  flex-direction: column;
  flex: 1;
}
.lbo {
  width: 100%;
  height: 180px;
}
</style>
